#!/usr/bin/env bash

SCRIPT_DIR="$(dirname "$(realpath "$0")")"
PROJECT_DIR="$(realpath "$SCRIPT_DIR"/../../../)"
OLD_DIR="$PWD"

if [[ -n $DEVENV_NIX ]]; then
	echo "Already inside of rsdk shell." >&2
	exit 1
fi

pushd "$PROJECT_DIR" || (
	echo "Unable to switch to project folder $PROJECT_DIR."
	exit 1
)
devenv shell -- "$@"
RET="$?"
popd || (
	echo "Unable to return to previous folder $OLD_DIR."
	exit 1
)

exit "$RET"
